/*
 * Copyright 2011 Digia Oyj - Pasi Hirvonen <pasi.hirvonen@digia.fi>
 *
 * XmlRpcRequest represents a single XML-RPC method call. It is posted to
 * the remote server through a XmlRpcConnection.
 *
 * Normally the authentication details set in the connection are used;
 * however, to send a single request using no authentication, call
 * setAnonymousQuery(True).
 *
 */

#ifndef TRACRPCREQUEST_H
#define TRACRPCREQUEST_H

#include <QtCore/QObject>
#include <QtCore/QSharedData>
#include <QtCore/QSharedDataPointer>
#include <QtCore/QList>

namespace XmlRpc {

class XmlRpcRequestPrivate;

class XmlRpcRequest
{
    Q_ENUMS(RpcMethodParamError)
public:
    enum RpcMethodParamError {
        NoError = 0
        // future use
    };
    /*
     * If the request is set to DoPropagate, the XML-RPC connection will emit
     * a finished() signal that anyone can listen to. With DoNotPropagate, you
     * must use RpcResponse's finished() signal. This allows you to create
     * "system" requests that don't propagate to other users of the XmlRpcConnection.
     */
    enum Propagate {
        DoPropagate,
        DoNotPropagate
    };

    explicit XmlRpcRequest(Propagate propagate = DoPropagate);
    XmlRpcRequest(const QString &method, Propagate propagate = DoPropagate);
    XmlRpcRequest(const QString &method, const QList<QVariant> &params,
                           Propagate propagate = DoPropagate);

    XmlRpcRequest(const XmlRpcRequest &other);
    virtual ~XmlRpcRequest();

    void setAnonymousQuery(bool value);
    bool anonymousQuery() const;

    void setMethod(const QString &method);
    QString method() const;

    Propagate propagate() const;

    RpcMethodParamError setParams(const QList<QVariant> &params);
    QList<QVariant> params() const;
    void addParam(const QVariant &variant);

private:
    friend class XmlRpcRequestPrivate;
    QSharedDataPointer<XmlRpcRequestPrivate> d;
};

} // namespace XmlRpc

#endif // TRACRPCREQUEST_H
